package com.info.zhiduoduo.common.validator;

import com.google.common.primitives.Ints;

import java.util.List;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class IntInValidator implements ConstraintValidator<IntIn, Integer> {

	private List<Integer> list;

	@Override
	public void initialize(IntIn constraintAnnotation) {
		list = Ints.asList(constraintAnnotation.value());
	}

	@Override
	public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) {
		return list.contains(value);
	}
}
